/**
 * https://leetcode-cn.com/problems/third-maximum-number/
 * 第三大的数
 * @param nums 
 */
const thirdMax = (nums: number[]): number => {
    // 1. 排序(从大到小)
    nums.sort((a, b) => b - a);

    // 去重
    nums = [...new Set(nums)]
    
    
    // 2 找到结果(默认为第一项)
    return nums[2] === undefined ? nums[2] : nums[0]
};

console.log(thirdMax([3, 3, 4, 3, 4, 3, 0, 3, 3]))